package com.web.dao;

import com.web.entity.UserExperience;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserExperienceMapper {
    @Delete({
        "delete from APP_USER_EXPERIENCE",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_USER_EXPERIENCE (user_id, theme, ",
        "synopsis, open_time, ",
        "end_time, create_time, ",
        "modify_time)",
        "values (#{userId,jdbcType=VARCHAR}, #{theme,jdbcType=VARCHAR}, ",
        "#{synopsis,jdbcType=VARCHAR}, #{openTime,jdbcType=TIMESTAMP}, ",
        "#{endTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(UserExperience record);

    int insertSelective(UserExperience record);

    @Select({
        "select",
        "id, user_id, theme, synopsis, open_time, end_time, create_time, modify_time",
        "from APP_USER_EXPERIENCE",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    UserExperience selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(UserExperience record);

    @Update({
        "update APP_USER_EXPERIENCE",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "theme = #{theme,jdbcType=VARCHAR},",
          "synopsis = #{synopsis,jdbcType=VARCHAR},",
          "open_time = #{openTime,jdbcType=TIMESTAMP},",
          "end_time = #{endTime,jdbcType=TIMESTAMP},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserExperience record);

    List<UserExperience> findByUserExperience(@Param("key") String key,@Param("value") String value);
}